home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Headers / misckit / MiscTime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-01  |  2.3 KB  |  97 lines

  1. //
  2. //    MiscTime.h -- a generic class to simplify manipulation of times
  3. //        Written by Don Yacktman Copyright (c) 1993 by Don Yacktman.
  4. //                Version 1.2.  All rights reserved.
  5. //        This notice may not be removed from this source code.
  6. //
  7. //    This object is included in the MiscKit by permission from the author
  8. //    and its use is governed by the MiscKit license, found in the file
  9. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  10. //    for a list of all applicable permissions and restrictions.
  11. //    
  12.  
  13. #import <appkit/appkit.h>
  14.  
  15. #define MISC_TIME_UNKNOWN_DOW -1    // for uncalced day of week
  16. #define MISC_TIME_MAX_MICROSECONDS 1000000
  17. #define MISC_TIME_MAX_SECONDS 60
  18. #define MISC_TIME_MAX_MINUTES 60
  19. #define MISC_TIME_MAX_HOURS 24
  20. #define MISC_TIME_MAX_DAYS 365
  21. #define MISC_TIME_MAX_MONTHS 12
  22.  
  23. @interface MiscTime:Object <NXTransport>
  24. {
  25.     BOOL isRelative; // if we are absolute date or a relative measure.
  26.     long microsecond, second, minute, hour, dow, day, month, year;
  27.     char *myStringValue;
  28.     @private BOOL _initted;
  29. }
  30.  
  31. + (int)daysInMonth:(int)aMonth ofYear:(int)aYear;
  32. + (int)daysUpToMonth:(int)aMonth ofYear:(int)aYear;
  33. + (int)isLeapYear:(int)aYear;
  34.  
  35. - init;
  36. - initWithCurrentTime;
  37. - initWithTime_t: (time_t)aTime;
  38.  
  39. - setYear:(int)t;
  40. - setMonth:(int)t;
  41. - setDayOfWeek:(int)t;
  42. - calcDayOfWeek;        // set the year, month, and day first.
  43. - setDay:(int)t;
  44. - setHour:(int)t;
  45. - setMinute:(int)t;
  46. - setSecond:(int)t;
  47. - setMicrosecond:(int)t;
  48. - setRelative:(BOOL)t;
  49. - (BOOL)isRelative;
  50.  
  51. - (int)_nintValue; // private method, does intValue w/o usecs.
  52. - (int)intValue;
  53. - (float)floatValue;
  54. - (double)doubleValue;
  55. - (const char *)stringValue;
  56. - (const char *)format:(const char *)fmtString;    
  57.  
  58. - (int)year;
  59. - (int)month;
  60. - (int)dayOfWeek;
  61. - (int)day;
  62. - (int)hour;
  63. - (int)minute;
  64. - (int)second;
  65. - (int)microsecond;
  66.  
  67. - addTime:aTime;
  68. - subtractTime:aTime;
  69.  
  70. - addMicroseconds:(long)t;
  71. - addSeconds:(long)t;
  72. - addMinutes:(long)t;
  73. - addHours:(long)t;
  74. - addDays:(long)t;
  75. - addWeeks:(long)t;
  76. - addMonths:(long)t;
  77. - addYears:(long)t;
  78.  
  79. - subtractMicroseconds:(long)t;
  80. - subtractSeconds:(long)t;
  81. - subtractMinutes:(long)t;
  82. - subtractHours:(long)t;
  83. - subtractDays:(long)t;
  84. - subtractWeeks:(long)t;
  85. - subtractMonths:(long)t;
  86. - subtractYears:(long)t;
  87.  
  88. - (BOOL)isAfter:aTime;
  89. - (BOOL)isEqual:aTime;
  90.  
  91. - copy;
  92. - copyTimeFrom:aTime;
  93. - read:(NXTypedStream *)stream;
  94. - write:(NXTypedStream *)stream;
  95.  
  96. @end
  97.